#include "dialog.h"
#include "ui_dialog.h"

#include <QDateTime>
#include <QFileInfoList>
#include<QComboBox>
Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Dialog)
{
    ui->setupUi(this);

}

Dialog::~Dialog()
{
    delete ui;
}


void Dialog::on_pushButtonOpen_clicked()
{
    QString path=QFileDialog::getOpenFileName(this,tr("Open File"),
                                 "/");

    ui->lineEditpath->setText(path);


//    ui->lineEditSize->clear();
//    ui->lineEditCreatTime->clear();
//    ui->lineEditReviseTime->clear();
//    ui->lineEditEnterTime->clear();


}

void Dialog::on_pushButtonInfoAll_clicked()
{
  QString path=ui->lineEditpath->text();
  QFileInfo info(path);

  qint64 filesize=info.size();
  QDateTime createtime=info.created();
  QDateTime lastmodifytime=info.lastModified();
  QDateTime lastaccesstime=info.lastRead();

  bool bfile=info.isFile();
  bool bhide=info.isHidden();
  bool bread=info.isReadable();
  bool bwrite=info.isWritable();
  bool bexecute=info.isExecutable();


  ui->lineEditCreatTime->setText(createtime.toString());
  ui->lineEditSize->setText(QString::number(filesize));
  ui->lineEditReviseTime->setText(lastmodifytime.toString());
  ui->lineEditEnterTime->setText(lastaccesstime.toString());

  ui->checkBoxFile->setCheckState(bfile?Qt::Checked:Qt::Unchecked);
  ui->checkBoxHide->setCheckState(bhide?Qt::Checked:Qt::Unchecked);
  ui->checkBoxReaderable->setCheckState(bread?Qt::Checked:Qt::Unchecked);
  ui->checkBoxWriteale->setCheckState(bwrite?Qt::Checked:Qt::Unchecked);
  ui->checkBoxExacute->setCheckState(bexecute?Qt::Checked:Qt::Unchecked);

}
